﻿using EnetaMvc.ApplicationServices;
using EnetaMvc.ApplicationServices.Dto;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;

namespace EnetaMvc.Web
{
    public class BaseController : Controller
    {
        protected void CopyErrorsToModelState(IEnumerable<ValidationResult> results)
        {
            foreach (var result in results)
                foreach(var memberName in result.MemberNames)
                {
                    ModelState.AddModelError(memberName, result.ErrorMessage);
                }
        }
    }
}